/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package upeu.cepre.business;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import upeu.cepre.model.Curso;

import upeu.cepre.util.DataBaseConexion;

/**
 *
 * @author Elvis Zanguetsu
 */
public class CursoManager {

    public Connection connection;

    public Curso finById(String idCurso) {
        Curso curso = new Curso();


        try {
            connection = DataBaseConexion.getConexion();
            PreparedStatement preparedStatement = connection.prepareStatement("select * from curso where idCurso=?");
            preparedStatement.setString(1, idCurso);
            ResultSet rs = preparedStatement.executeQuery();

            if (rs.next()) {

                curso.setIdCurso(rs.getString("idCurso"));
                curso.setNombre(rs.getString("nombre"));
                curso.setDetalle(rs.getString("detalle"));
            }

            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return curso;
    }
}
